<?php require_once APPPATH.'views/bootstrap/snip_userbox.php' ?>

<?php
	function followProjectTag($record, $requestContext)
	{
		$sessionInfo = $requestContext->sessionInfo;
		if (isset($record->params->member_type) && $record->params->member_type != NULL) {
			return "[".$record->params->member_type."]";
		}
		$retval = '<a href="'. controller_base_path($requestContext).'/Connection/follow?type=Project&sid='.$record->sid.'">Follow</a>';
		$retval = $retval. ' | <a href="'. controller_base_path($requestContext).'/Project/requestjoin?projectSid='.$record->sid.'&userSid='.$sessionInfo->userInfo['userSid'].'&type=collab">Join</a>';
		return $retval;
	}

?>
							<h4>Search Result</h4>
							
<?php //print_r($hitsByType) ?>
<?php foreach ($hitsByType as $type => $hitsOfAType) {?>

							<h5><?php echo $type ?></h5>
							<hr />
<?php foreach ($hitsOfAType->entries as $hitEntry) {
	$record = $hitEntry->record;
?>
							<div style="width:100%; display:inline-block;">
<?php if (strcasecmp($type, "Project") == 0) { ?> 
								<img src="img/profile-pic.jpg" style="float:left; padding:5px">
								<div style="margin-right:50px"><b><a href="<?php echo controller_base_path($requestContext).'/Project/'.$record->sid;?>"><?php echo $record->name; ?></a> </b> by <a href="<?php echo controller_base_path($requestContext); ?>/Profile/view?creatorSid=<?php echo $sessionInfo->userInfo['userSid']; ?>"><?php echo $record->ownerDisplayName; ?></a><br />
									<?php echo $record->goal; ?>
									<p>Required Skills: <?php echo $record->requiredSkillTagNamesCsv; ?></p>
									<div style="float:right"><?php echo followProjectTag($record, $requestContext); ?></div>
								</div>
<?php } else if (strcasecmp($type, "Profile") == 0) { ?> 
								<img src="<?php echo profile_img_url( $record->creatorDto->profileImageSid, 40) ?>" style="float:left; padding:5px">
								<div style="margin-right:50px"><b><a href="<?php echo controller_base_path($requestContext).'/Profile/'.$record->creatorSid;?>"><?php echo $record->creatorDto->displayName; ?></a></b> from <?php echo $record->currentLocation; ?><br />
									<?php echo $record->highlight; ?>
									<p>Skills: <?php echo $record->skillTagNamesCsv; ?></p>
									<div class="float:right"><?php echo connectUserTag($record, $requestContext); ?></div>
								</div>
<?php } else if (strcasecmp($type, "Post") == 0) { ?> 
<?php //echo print_r($record); ?>
								<img src="<?php echo profile_img_url( $record->creatorProfileImageSid, 40) ?>" style="float:left; padding:5px">
								<div style="margin-right:50px">By <a href="#"><?php echo $record->creatorDisplayName; ?></a><br />
									<?php echo $record->body; ?>
								</div>
<?php } ?>
								<br />
							</div>
<?php } // entries?>
<?php } // types?>
							
						